package com.stylismo.intellij.inspection.groovy;

import com.intellij.psi.PsiElement;
import com.stylismo.intellij.inspection.NullabilityAnnotationsInspection;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.codeInspection.BaseInspection;
import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor;
import org.jetbrains.plugins.groovy.codeInspection.GroovyFix;

import javax.swing.*;

/**
 * Name: GroovyNullabilityAnnotationsInspection<br>
 * User: Yao<br>
 * Date: 2017/11/5<br>
 * Time: 01:14<br>
 */
public class GroovyNullabilityAnnotationsInspection extends BaseInspection {
    private final NullabilityAnnotationsInspection nullabilityAnnotationsInspection = new NullabilityAnnotationsInspection();

    @Nullable
    @Override
    public JComponent createOptionsPanel() {
        return nullabilityAnnotationsInspection.createOptionsPanel();
    }

    @NotNull
    @Override
    protected BaseInspectionVisitor buildVisitor() {
        return new GroovyAddPackageInfoWithNullabilityDefaultsVisitor(nullabilityAnnotationsInspection);
    }

    @Override
    @Nls
    @NotNull
    public String getGroupDisplayName() {
        return "Probable bugs";
    }

    @Override
    @Nls
    @NotNull
    public String getDisplayName() {
        return "Missing @NotNull/@Nullable annotation";
    }

    @Override
    protected String buildErrorString(Object... args) {
        return "Missing @NotNull/@Nullable #loc";
    }

    @Override
    public boolean isEnabledByDefault() {
        return true;
    }

    @Override
    public GroovyFix buildFix(@NotNull PsiElement location) {
        return null;
    }

}
